package com.bootdo.stock.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

import com.bootdo.stock.dao.StockDao;
import com.bootdo.stock.domain.StockDO;
import com.bootdo.stock.service.StockService;



@Service
public class StockServiceImpl implements StockService {
	@Autowired
	private StockDao stockDao;
	
	@Override
	public List<StockDO> list(Map<String, Object> map){
		return stockDao.list(map);
	}

	@Override
	public List<StockDO> listP(Map<String, Object> map){
		return stockDao.listP(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return stockDao.count(map);
	}

	@Override
	public int countP(Map<String, Object> map){
		return stockDao.countP(map);
	}
	
	@Override
	public int save(Long goodsId){
		if(stockDao.getByGsId(goodsId)>0) {
			return -1;
		}
		return stockDao.save(new StockDO(goodsId));
	}
	
	@Override
	public int update(Long goodsId,Integer quNum,Integer outNum,Integer reNum,Integer badNum){
		Map<String, Object> map = new HashMap<String,Object>();
		map.put("goodsId", goodsId);
		map.put("quNum", quNum);
		map.put("outNum", outNum);
		map.put("reNum", reNum);
		map.put("badNum", badNum);
		return stockDao.update(map);
	}
	
	@Override
	public int remove(Long goodsId){
		return stockDao.remove(goodsId);
	}

	@Override
	public StockDO getStockByGsId(Long goodsId){
		return stockDao.getStockByGsId(goodsId);
	}
	
}
